import UIKit

extension UIAlertController {
    //在指定视图控制器上弹出普通消息提示框
    static func showAlert(title: String? = nil,btnName: String? = "确定", message: String) {
        let vc = topVC!
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        alert.view.tintColor = UIColor.colBlack
        alert.addAction(UIAlertAction(title: btnName, style: .cancel))
        vc.present(alert, animated: true)
    }

    //在根视图控制器上弹出确认框
    static func showConfirm(title: String? = nil,btnName: String? = "确定", message: String, confirm: ((UIAlertAction)->Void)?) {
        let vc = topVC!
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        alert.view.tintColor = UIColor.colBlack
        alert.addAction(UIAlertAction(title: "取消", style: .cancel))
        alert.addAction(UIAlertAction(title: "确定", style: .default, handler: confirm))
        vc.present(alert, animated: true)
    }
}
